<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <title>注册</title>
    <style>
        body{
            background: url("sea.jpg");
            display: flex;
            justify-content: center;
            align-items: center;
            color: aqua;
            margin-top: 200px;
        }
    </style>
</head>
<body>
      <form id="registerForm">
             <div>
                 <label>用户名 : <input type="text" name="name"></label>
             </div>
             <div>
                <label>密&nbsp;&nbsp;&nbsp;码 : <input type="password" name="password"></label>
            </div>
            <div>
                <button type="submit" style="width: 60px;"> 注册</button>
            </div>
      </form>

<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"> </script>
<script>
    const $form=$('#registerForm')
        $form.on('submit',(e)=>{
            e.preventDefault()
            const name =$form.find('input[name=name]').val()
            const password=$form.find('input[name=password]').val()
            console.log(name,password)
            $.ajax({
                method:'POST',
                url:'/register',
                contentType:'text/json;charset=UTF-8',
                data:JSON.stringify({name,password})
            }).then(()=>{alert('注册成功')
            location.href='/sign_in.html'},()=>{})
        })
</script>
</body>
</html> 